package com.ming.server.dubbo.service;

import java.rmi.RemoteException;
import java.util.Date;
import java.util.List;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ming.server.dubbo.model.PersonEntity;

public class ChatAction {
	private DemoServer demoServer;
	
	public void SayHello() {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] { "applicationConsumer.xml" });
		context.start();
		DemoServer demoServer = (DemoServer) context.getBean("demoService");
		System.out.println("client:" + demoServer.sayHello("zx" + "1:" + new Date()) + "3:" + new Date());
		
	}
	
	public void Persion() {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] { "applicationConsumer.xml" });
		this.demoServer = context.getBean(DemoServer.class);
		List<PersonEntity> personList = this.demoServer.GetList();
		for(PersonEntity person:personList){
			System.out.println("ID:"+person.getId()+" Age:"+person.getAge()+" Name:"+person.getName());
		}	
	}
	
	/**
	 * 登录
	 */
	public void Login() {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] { "applicationConsumer.xml" });
		this.demoServer = context.getBean(DemoServer.class);
		try {
			boolean isLogin = this.demoServer.checkLogin("admin", "123");
			if (isLogin) {

				System.out.println("登陆成功！");

			} else {

				System.out.println("登陆失败！");

			}

		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
